public class 结构体 {
    public static void main(String[] args) {
        //求水仙花数
        //1.先知道多少位数
        for (int i = 0; i <= 999999; i++) {
            int count = 0;
            int temp = i;
            while (temp != 0) {

                temp /= 10;
                count ++;
            }
            temp = i;
            //取他的数字
            int sum = 0;
            while (temp != 0) {

               sum += Math.pow(temp % 10, count);
               temp /= 10;//减去他的位数
            }
            if (sum == i) {
                System.out.println(count + "的幂级数是" + i);
            }

        }


    }
    public static void main15(String[] args) {
        //判断素数
        int i = 9;
        int j = 0;
        for (j = 2; j <= Math.sqrt(i); j++) {//开根号
            if (i % j == 0) {
                System.out.println("不是素数");
                break;
            }
        }
        if (j > Math.sqrt(i)) {
            System.out.println("是素数");
        }
    }
    public static void main14(String[] args) {
        //5!+4!+....
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            int j = 1;

            for(int s = 1; s <= i; s++) {
                j *= s;
            }
            sum += j;
        }
        System.out.println(sum);
    }
    public static void main13(String[] args) {

    }
    public static void main12(String[] args) {
        //for类型
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println(sum);
    }
    public static void main11(String[] args) {
        //continue的用法
        int i = 0;
        while (i < 10){
            //System.out.print(i + " ");
            i++;
            if (i == 3) {
                continue;
            }
            System.out.print(i + " ");
        }
    }
    public static void main10(String[] args) {

        //5!+4!+....
//        int j = 1;
//        int i = 1;
//        int sum = 0;
//        int a = 1;
//        while (j <= 5) {
//            while (i <= j) {
//                a *= i;
//                i++;
//                sum += a;
//            }
//            j++;
//        }
//        System.out.println(sum);
        int j = 1;
        int sum = 0;
        while (j <= 5) {
            int i = 1;
            int ret = 1;
            while (i <= j) {
                ret *= i;
                i++;
            }

            sum += ret;
            j++;

        }
        System.out.println(sum);
    }
    public static void main9(String[] args) {
        //5的阶乘
        int i = 1;
        int sum = 1;

        while (i <= 5) {
            sum *= i;
            i++;
        }
        System.out.println(sum);
    }
    public static void main8(String[] args) {
        //判断闰年
        int year = 2025;//ctrl + alt + l 自动帮忙整理代码
        if ((year % 4 == 0 && year % 100 != 00) || (year % 400 == 0)) {
            System.out.println(year + "是闰年");

        }else {
            System.out.println(year + "不是闰年");
        }
    }
    public static void main7(String[] args) {
        //100内奇数的和
        int i = 0;
        int sum = 0;
        while (i <= 100) {
            sum += i;
            i++;

        }
        System.out.println(sum);//sum.sout
    }
    public static void main6(String[] args) {
        int i = 1;
        while (i <= 10) {
            System.out.println(i);//i.sout
            i++;
        }
    }
    public static void main5(String[] args) {
        //写一个switch
        int i = 8;
        switch (i) {
            case 1:
                System.out.println("星期一");
                break;
            case 3:
                System.out.println("星期三");
                break;
            default:
                System.out.println("输入错误");
        }
    }
    public static void main4(String[] args) {
        int i = 1;
        while (i <= 100) {
            if (i % 3 != 0 && i % 4 != 0) {
                i++;
                continue;
            }

            System.out.print(i + " ");
            i++;
        }
    }
    public static void main3(String[] args) {
        //判断一个数是不是偶数
        int a = 9;
        if (a % 2 == 0) {
            System.out.println(a + "是偶数");
        }else {
            System.out.println(a + "不是偶数");
        }
    }
    public static void main2(String[] args) {
        //if else 结构
        int a = 5;
        if (a > 5) {//里边一定是布尔类型
            System.out.println(a + "大于5");
        }else if (a < 5) {
            System.out.println(a + "小于5");
        }else {
            System.out.println(a + "等于5");
        }

    }
    //顺序结构
    public static void main1(String[] args) {
        System.out.println("aaa");
        System.out.println("bbb");
        System.out.println("ccc");
    }
}
